// fillings for player header
#include "Includes.hpp" // includes for project
#include "Player.hpp" // class declarations

////////////////////////////// EXTERNS ///////////////////////////////
extern RobustIO robio;

////////////////////////////// CONSTRUCTORS //////////////////////////
Player::Player() { // default constructor // should not be used
    cout << "\n\tyou are doing it wrong!\n\tsee player class"; // print error
}

Player::Player(int uniqueid) : Num_element(uniqueid) {
    name = robio.readName("players"); // get name of player
    address = robio.readAddress("players"); // get address
}

Player::Player(ifstream* in, int uniqueid) : Num_element(uniqueid) {
    name = robio.readFileString(in); // read name
//    (*in).ignore(2, '#'); // ignore leftover delimiter
    address = robio.readFileString(in); // read address
//    (*in).ignore(2, '#'); // ignore leftover delimiter
}

/////////////////////////// CLASS FUNCTIONS //////////////////////////
void Player::display() {
    cout << "\n" << number << ' ' << name << ' ' << address;
}

void Player::writeToFile(ofstream* out) {
    (*out) << number << " #" // write number and delimiter
	   << name << " #" // write name and delimiter
	   << address << " #";  // write address and delimiter
}

////////////////////////////// GETTERS ///////////////////////////////
char* Player::getName() {
    return this->name; // return player's name
}

char* Player::getAddress() {
    return this->address; // return player's address
}

int Player::getNumber() {
    return this->number;
}
